<template>
	<view>
		<button type="primary" @tap="handlePhone">打开相册</button>
		<button type="primary" open-type="getPhoneNumber" @tap="getPhoneNumber">获取手机号码</button>
		<block v-for="item in imgArr" :key="item">
			<image class="w-90" :src="item" mode="widthFix"></image>
		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgArr: []
			};
		},
		methods: {
			getPhoneNumber(e) {
				console.log(e);
			},
			handlePhone() {
				uni.chooseImage({
					sizeType: ['original', 'compressed'], 
					sourceType: ['album'], //从相册选择
					success: function(res) {
						uni.previewImage({
									urls: res.tempFilePaths,
									longPressActions: {
										itemList: ['发送给朋友', '保存图片', '收藏'],
										success: function(data) {
											console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
										},
										fail: function(err) {
											console.log(err.errMsg);
										}
									}
								});
					}
				})
			}
		},
	}
</script>

<style lang="scss">

</style>
